var webpack = require('webpack');
var path = require('path');
var baseConf = require("./base.conf.js");
var merge = require("webpack-merge");

// 发布的资源路径,绝对路径
var pro_cdn_path = "../";

var proConf = {
    output:{
        filename: "[name].js",
        chunkFilename: "[name].[id].c.js?v=[chunkhash]",
        path: "/dist/scripts/",
        // 设置到html的目录
        publicPath: pro_cdn_path + "scripts/"
    },
    plugins:[

        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            filename: 'vendor.js?v=[hash:4]',
            minChunks: function (module, count) {
                // any required modules inside node_modules are extracted to vendor
                return (
                    module.resource &&
                    /\.js$/.test(module.resource) &&
                    module.resource.indexOf(
                        path.join(__dirname, 'node_modules')
                    ) === 0
                )
            }
        }),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'manifest',
            chunks: ['vendor']
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            // preserveComments:'all',
            compress: {
                warnings: false
            }
        })
    ]
};


module.exports = merge(baseConf, proConf)